#猜数字
num = randint(1, 30)
while True:
    guess = int(input("请输入一个数字："))
    if guess > num:
        print("太大了")
    elif guess < num:
        print("太小了")
    else:
        print("猜对了")
        break  # 结束循环

#打印菱形
for i in range(1, 11 + 1, 2):
    print(("*" * i).center(11))  #center 字符串居中
for i in range(9, 0, -2):
    print(("*" * i).center(11))

# 打印100以内的完数
for i in range(1, 100 + 1):
    sum = 0
    for j in range(1, i):
        if i % j == 0:
            sum += j
    if sum == i:
        print(i)

# 打印斐波那契数列
for i in range(1, 10 + 1):
    for j in range(1, i + 1):
        print(j, end="\t")
    print()

# 打印九九乘法表
for i in range(1, 10 + 1):
    for j in range(1, i + 1):
        print("%d*%d=%d" % (j, i, j * i), end="\t")
    print()

#打印100以内质数
def print_primes(n):
    for i in range(2, n):
        is_prime = True
        for j in range(2, int(i ** 0.5)+1):
            if i % j == 0:
                is_prime = False
                break
        if is_prime:
            print(i)
print_primes(100)

#打印水仙花数
for i in range(100,1000):
    ge=i%10
    shi=i//10%10
    bai=i//100
    if ge**3+shi**3+bai**3==i:
        print(i)